﻿using System;
using com.ddmresources.EnumMetadata.Core;

namespace com.ddmresources.EnumMetadata.Samples
{
    /// <summary>
    /// This class shows some examples of custom extensions that someone using the EnumMetadata library might write.
    /// 
    /// The point of these extensions is to be syntactic sugar that lets the consumer write code like:
    /// var result = HelpTopic.ConstructionView.Info().Id rather than
    /// var result = HelpTopic.ConstructionView.Info<IHelpTopicInfo>().Id, which is the native call that the
    /// EnumMetadata library provides.
    /// 
    /// These extension methods sould be named "Info", take a parameter of an enum instance, and return the strongly typed
    /// metadata object associated (through attributes) with that enum instance.  These extension methods will work with both static
    /// and dynamic metadata attributes
    /// </summary>
    public static class CustomEnumExtensions
    {                
        //underlying enum is of dynamic type
        public static IClientStatusInfo Info(this ClientStatus clientStatus)
        {
            var info = clientStatus.Info<IClientStatusInfo>();

            return info;
        }

        //underlying enum is of dynamic type
        public static IClientStatusInfo InfoLax(this ClientStatus clientStatus)
        {
            var info = clientStatus.InfoLax<ClientStatusInfo>();

            return info;
        }

        //underlying enum is of static type
        public static IHelpTopicInfo Info(this HelpTopic helpTopic)
        {
            var info = helpTopic.Info<IHelpTopicInfo>();

            return info;
        }

        public static IHelpTopicInfo InfoLax(this HelpTopic helpTopic)
        {
            var info = helpTopic.InfoLax<HelpTopicInfoAttribute>();

            return info;
        }

    }
}
